{$CLEO .cs}
{$USE CLEO+}
{$USE newOpcodes}
{$USE ini}

0000: NOP

script_name "RONTSCR"

// By ArtemQa146


//  cleo+
if
    0AA2: 31@ = load_dynamic_library "CLEO+.cleo"
then
    if
        0AA4: 30@ = get_dynamic_library_procedure "GetCleoPlusVersion" library 31@
    then
        0AA7: call_function_return 30@ num_params 0 pop 0 29@
        if
            not 29@ >= 0x1020000
        then
            0AD1: show_formatted_text_highpriority "Cleo+ 1.2.0 (or higher) version is required, the Weapon Details mod is disabled" time 15000
            0AA3: free_dynamic_library 31@
            0A93: terminate_this_custom_script
        end
        0AA3: free_dynamic_library 31@
    end
else
    0AD1: show_formatted_text_highpriority "Cleo+ 1.2.0 (or higher) version is required, the Weapon Details mod is disabled" time 15000
    0AA3: free_dynamic_library 31@
    0A93: terminate_this_custom_script
end

const
    bit_sets = 31@
    pickup_up = 30@
    ammo_txd = 29@
    plus_txd = 28@
    vest_txd = 27@
    dollar_txd = 26@
    check_plus = 25@
    check = 24@
    check_money = 23@
    check_vest = 22@
    alpha_ini = 21@
    position_i_x = 20@
    position_i_y = 19@
    Text_alignment = 18@
    Time_ini = 17@
    check_ammo_1 = 9@
    check_ammo_2 = 10@
    check_ammo_3 = 11@
    check_ammo_4 = 12@
    check_ammo_5 = 13@
    check_ammo_6 = 14@
    check_ammo_7 = 15@
    check_ammo_8 = 16@
    pickup_check = 8@
    number_show = 5@    // 
    progress = 4@       // 
    ammo1 = 1
    plus = 2
    vest = 3
    dollar = 4
    // bit
    pickup_ini = 0
    ammo_ini = 1
    money_ini = 2
    health_ini = 3
    armor_ini = 4
end

0AF2: position_i_x = read_float_from_ini_file "cleo\Replenishment on the screen.ini" section "Settings" key "Position X"
0AF2: position_i_y = read_float_from_ini_file "cleo\Replenishment on the screen.ini" section "Settings" key "Position Y"
0AF0: alpha_ini = read_int_from_ini_file "cleo\Replenishment on the screen.ini" section "Settings" key "Alpha"
0AF0: Text_alignment = read_int_from_ini_file "cleo\Replenishment on the screen.ini" section "Settings" key "Text alignment"
0AF0: Time_ini = read_int_from_ini_file "cleo\Replenishment on the screen.ini" section "Settings" key "Time"

08C3: clear Bit_sets bit pickup_ini
0AF0: 0@ = read_int_from_ini_file "cleo\Replenishment on the screen.ini" section "Settings" key "Show only after pickup"
if 0@ == 1
then 08BD: set Bit_sets bit pickup_ini
end

08C3: clear Bit_sets bit ammo_ini
0AF0: 0@ = read_int_from_ini_file "cleo\Replenishment on the screen.ini" section "Settings" key "Ammo"
if 0@ == 1
then 08BD: set Bit_sets bit ammo_ini
end

08C3: clear Bit_sets bit money_ini
0AF0: 0@ = read_int_from_ini_file "cleo\Replenishment on the screen.ini" section "Settings" key "Money"
if 0@ == 1
then 08BD: set Bit_sets bit money_ini
end

08C3: clear Bit_sets bit armor_ini
0AF0: 0@ = read_int_from_ini_file "cleo\Replenishment on the screen.ini" section "Settings" key "Armor"
if 0@ == 1
then 08BD: set Bit_sets bit armor_ini
end

08C3: clear Bit_sets bit health_ini
0AF0: 0@ = read_int_from_ini_file "cleo\Replenishment on the screen.ini" section "Settings" key "Health"
if 0@ == 1
then 08BD: set Bit_sets bit health_ini
end

// Load texture
0390: load_txd_dictionary 'rontscr'
038F: load_texture "ammo" as 1
0E3C: get_texture_from_sprite 1 store_to ammo_txd
038F: load_texture "dollar" as 2
0E3C: get_texture_from_sprite 2 store_to dollar_txd
038F: load_texture "plus" as 3
0E3C: get_texture_from_sprite 3 store_to plus_txd
038F: load_texture "vest" as 4
0E3C: get_texture_from_sprite 4 store_to vest_txd
0391: release_textures

check_plus = -1
check_money = -1
check_ammo_1 = -1
check_ammo_2 = -1
check_ammo_3 = -1
check_ammo_4 = -1
check_ammo_5 = -1
check_ammo_6 = -1
check_ammo_7 = -1
check_ammo_8 = -1
check_vest = -1
check = 0


while true
wait 0
    if
        player.Defined(0)
    then
        
        if or
            0E25: is_on_cutscene
            0EB7: is_on_scripted_cutscene
            not is_hud_visible
        then
            continue
        end

        // 
        if
            08B7:   test Bit_sets bit health_ini
        then
            if
                check_plus == -1
            then
                0226: check_plus = actor $player_actor health
            end

            0226: 1@ = actor $player_actor health
            if
                001D:   1@ > check_plus  // (int)
            then
                0062: 1@ -= check_plus  // (int)
                0085: number_show = 1@ // (int)
                0226: check_plus = actor $player_actor health
                check = plus
                timera = 0
            else
                if
                    001D:   check_plus > 1@  // (int)
                then
                    0226: check_plus = actor $player_actor health
                end
            end
        end
        
        
        // 
        if
            08B7:   test Bit_sets bit armor_ini
        then
            if
                check_vest == -1
            then
                04DD: check_vest = actor $PLAYER_ACTOR armour
            end

            04DD: 1@ = actor $PLAYER_ACTOR armour
            if
                001D:   1@ > check_vest  // (int)
            then
                0062: 1@ -= check_vest  // (int)
                0085: number_show = 1@ // (int)
                04DD: check_vest = actor $PLAYER_ACTOR armour
                check = vest
                timera = 0
            else
                if
                    001D:   check_vest > 1@  // (int)
                then
                    04DD: check_vest = actor $PLAYER_ACTOR armour
                end
            end
        end
        
        
        // 
        if
            08B7:   test Bit_sets bit money_ini
        then
            if
                check_money == -1
            then
                010B: check_money = player $PLAYER_CHAR money
            end

            010B: 1@ = player $PLAYER_CHAR money
            if
                001D:   1@ > check_money  // (int)
            then
                0062: 1@ -= check_money  // (int)
                0085: number_show = 1@ // (int)
                010B: check_money = player $PLAYER_CHAR money
                check = dollar
                timera = 0
            else
                if
                    001D:   check_money > 1@  // (int)
                then
                    010B: check_money = player $PLAYER_CHAR money
                end
            end
        end
        
        
        // 
        if
            08B7:   test Bit_sets bit ammo_ini
        then
            Progress = 0
            for 0@ = 3 to 10 step 1
            04B8: get_weapon_data_from_actor $PLAYER_ACTOR slot 0@ weapon 3@ ammo 2@ model 1@ // 2 - melle, 3 - pistol, 4 shotg, 5 uzi, 6 rifle, 7 sniper, 8 heavy, 9 grenade, 10 other
                if
                    2@ > 0
                then
                    if
                        check_ammo_1(Progress,1i) == -1
                    then
                        041A: check_ammo_1(Progress,1i) = actor $PLAYER_ACTOR weapon 3@ ammo
                    end

                    041A: 1@ = actor $PLAYER_ACTOR weapon 3@ ammo
                    if
                        001D:   1@ > check_ammo_1(Progress,1i)  // (int)
                    then
                        0062: 1@ -= check_ammo_1(Progress,1i)  // (int)
                        0085: number_show = 1@ // (int)
                        041A: check_ammo_1(Progress,1i) = actor $PLAYER_ACTOR weapon 3@ ammo
                        check = ammo1
                        timera = 0
                        break
                    else
                        if
                            001D:   check_ammo_1(Progress,1i) > 1@  // (int)
                        then
                            041A: check_ammo_1(Progress,1i) = actor $PLAYER_ACTOR weapon 3@ ammo
                        end
                    end
                else
                    check_ammo_1(Progress,1i) = -1
                end
            Progress += 1
            end
        end
        
        // 
        if
            08B7:   test Bit_sets bit pickup_ini
        then
            if
                pickup_check == -1
            then
                0A8D: pickup_check = read_memory 0x978624 size 2 virtual_protect 0 // 0x978624   _ZN8CPickups20CollectedPickUpIndexE dw ?
            end

            0A8D: 1@ = read_memory 0x978624 size 2 virtual_protect 0 // 0x978624   _ZN8CPickups20CollectedPickUpIndexE dw ?
            if
                001D:   1@ > pickup_check  // (int)
            then
                0A8D: pickup_check = read_memory 0x978624 size 2 virtual_protect 0 // 0x978624   _ZN8CPickups20CollectedPickUpIndexE dw ?
                pickup_up = true
            else
                if and
                    1@ == 0
                    pickup_check >= 1
                then
                    0A8D: pickup_check = read_memory 0x978624 size 2 virtual_protect 0 // 0x978624   _ZN8CPickups20CollectedPickUpIndexE dw ?
                    pickup_up = true
                end
            end
        else
            pickup_up = true
        end



        if and
            pickup_up == true
            001D:   Time_ini > timera  // (int)
            check > 0
        then
            if check == plus
            then 0E1E: draw_texture_plus plus_txd event 2 pos position_i_x position_i_y size 13.0 13.0 angle 0.0 0 1 0 0 rgba alpha_ini alpha_ini alpha_ini alpha_ini //  
            end
            if check == vest
            then 0E1E: draw_texture_plus vest_txd event 2 pos position_i_x position_i_y size 13.0 13.0 angle 0.0 0 1 0 0 rgba alpha_ini alpha_ini alpha_ini alpha_ini //  
            end
            if check == dollar
            then 0E1E: draw_texture_plus dollar_txd event 2 pos position_i_x position_i_y size 13.0 13.0 angle 0.0 0 1 0 0 rgba alpha_ini alpha_ini alpha_ini alpha_ini //  
            end
            if check == ammo1
            then 0E1E: draw_texture_plus ammo_txd event 2 pos position_i_x position_i_y size 13.0 13.0 angle 0.0 0 1 0 0 rgba alpha_ini alpha_ini alpha_ini alpha_ini //  
            end
            0AC6: 1@ = label @buffer pointer
            0AD3: 1@ = string_format "+%i" number_show
            0087: 2@ = position_i_x // (float)
            0087: 3@ = position_i_y // (float)
            if
                Text_alignment == 1
            then
                2@ += 5.5
                3@ -= 5.7
            else
                2@ -= 5.5
                3@ -= 5.7
            end
            0E63: print 1@ event 2 at 2@ 3@ scale 0.3 0.6 fixAR 1 style 1 prop 0 align Text_alignment wrap 640.0 justify 0 color alpha_ini alpha_ini alpha_ini alpha_ini outline 0 shadow 0 dropColor 0 0 0 0 background 0 backColor 0 0 0 0
        else
            if
                001D:   timera > Time_ini  // (int)
            then
                check = 0
                pickup_up = false
            end
        end

    end
end



:buffer
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP
0000: NOP